<template>
  <div class="vod-course-item" @click.stop="goToCourseDetail()">
    <div class="vod-course-item-comp">
      <div class="vod-course-thumb">
        <img :src="item.thumb" />
      </div>
      <div class="vod-course-body">
        <div class="vod-course-title">{{ item.title }}</div>
        <div class="vod-course-info">
          <div class="vod-course-sub">{{ item.user_count }}人已订阅</div>
          <div class="vod-course-charge">
            <div v-if="item.is_free" class="free-text">免费</div>
            <div v-else class="charge-text">
              <span class="unit">￥</span>{{ item.charge }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: ["item","token"],
  components: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {
    goToCourseDetail: function () {
       if(this.token){
        this.$router.push({
          path: "/vod/detail",
          query: {
            id: this.item.id,
          },
        })
       }
       else{
        this.$router.push({
          path: '/Register',
        })
       }
    },
  },
  created() {},
  mounted() {},
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {},
};
</script>
<style lang='less' scoped>
.vod-course-item {
  width: 100%;
  display: flex;
  padding-top: .4rem;
  margin-bottom: 0.4rem;
  .vod-course-item-comp {
    width: 100%;
    height: auto;
    display: flex;
    .vod-course-thumb {
      width: 120px;
      height: 90px;
      margin-right: 10px;
      img {
        width: 120px;
        height: 90px;
        border-radius: 4px;
      }
    }

    .vod-course-body {
      flex: 1;
      padding-top: 5px;
      .vod-course-title {
        width: 100%;
        height: 40px;
        float: left;
        font-size: 15px;
        font-weight: 500;
        color: #171923;
        line-height: 20px;
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        margin-bottom: 15px;
      }

      .vod-course-info {
        width: 100%;
        height: auto;
        display: flex;
        align-items: center;
        .vod-course-sub {
          flex: 1;
          text-align: left;
          font-size: 12px;
          font-weight: 400;
          color: #999;
          line-height: 12px;
        }

        .vod-course-charge {
          flex: 1;
          text-align: right;
          font-size: 18px;
          line-height: 18px;
          font-weight: 600;
          .free-text {
            font-size: 14px;
            font-weight: 600;
            color: #52c41a;
          }
          .charge-text {
            color: #ff5858;
            .unit {
              font-size: 14px;
            }
          }
        }
      }
    }
  }
}
</style>